package Utils

import (
	"bytes"
	"encoding/gob"
	"fmt"
)

func EncodeGob(pStruct interface{}) []byte  {
	var ioStream bytes.Buffer
	enc := gob.NewEncoder(&ioStream)
	err := enc.Encode(pStruct)
	if err != nil{
		fmt.Println(err)
		return nil
	}
	return ioStream.Bytes()
}


func DecodeGob(data []byte, pStruct interface{}) bool  {
	ioStream := bytes.NewBuffer(data)
	enc := gob.NewDecoder(ioStream)
	err := enc.Decode(pStruct)
	if err != nil{
		fmt.Println(err)
		return false
	}
	return true
}
